package vincent.com.layouttest;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBarActivity;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import vincent.com.layouttest.view.CustomViewGroup;

/**
 * Created by chenzhengwen on 2015/7/17.
 */
public class CustomViewGroupActivity extends ActionBarActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_custom_viewgroup);

        CustomViewGroup customViewGroup = new CustomViewGroup(this);
        customViewGroup.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

        for(int i = 0; i < 6; i++){
            LinearLayout wrapper = new LinearLayout(this);
            wrapper.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            wrapper.setOrientation(LinearLayout.HORIZONTAL);
            wrapper.setBackgroundColor(Color.rgb(200, 200, 200));

            TextView txt = new TextView(this);
            txt.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            txt.setTextColor(Color.WHITE);
            txt.setBackgroundColor(Color.BLACK);
            txt.setText("Item " + i);

            wrapper.addView(txt);
            customViewGroup.addView(wrapper);
        }


        setContentView(customViewGroup);
    }
}
